<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/6/6
  Time: 21:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>登录页面</title>
    <!-- 使用 BootCDN 提供的 Bootstrap 4 CDN -->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Header -->
<header class="bg-primary text-white text-center py-3">
    <h1>学生信息管理系统</h1>
</header>

<!-- 登录表单 -->
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-primary text-white text-center">
                    <h3>登录</h3>
                </div>
                <div class="card-body">
                    <form id="loginForm" onsubmit="return validateForm()"  >
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" required>
                        </div>
                        <div class="form-group">
                            <label for="password">密码</label>
                            <input type="password" class="form-control" id="password" name="password" required>
                        </div>
                        <button type="submit" class="btn btn-primary btn-block">登录</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Footer -->
<footer class="bg-primary text-white text-center py-3 mt-5">
    <p>&copy; 2024 学生信息管理系统. 保留所有权利.</p>
</footer>

<!-- 引入 Bootstrap 4 和 jQuery -->
<!-- 表单验证脚本 -->
<!-- 使用 BootCDN 提供的 jQuery 和 Bootstrap 4 JS CDN -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/popper.js/2.9.3/umd/popper.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
    function validateForm() {
        const username = document.getElementById('username').value;
        const password = document.getElementById('password').value;
        const validUsername = 'admin';
        const validPassword = 'password';

        if (username === validUsername && password === validPassword) {
            // 登录成功，重定向到管理页面
            location.href = 'management.jsp';
            return false; // 阻止表单的默认提交
        } else {
            alert('用户名或密码错误');
            return false;
        }
    }
</script>
</body>
</html>
